﻿
function goshopnow(){
	var uid;
	if ($.session.get("user") == null){
		alert("请您先登录!");
		window.location.href = "../index.html";
	}
	data = JSON.parse($.session.get("user"));
	uid = data.id;
	var pid;
	var url = window.location.search;//获取url中“？”后面的字符串   
	if(url.length != -1){
			pid = url.substr(url.indexOf("=")+1);
	}
	// order/shop
	jQuery.ajax({
		type: "post",
		url: "/order/shop",
		data: {"uid": uid, "pid": pid},
		dataType: "json",
		success: function(res){
			if (res.code == 200) {//200正确
				if (res.data.code != 33) {
					// 发生异常情况，弹出提示信息刷新当前页面
					alert(res.data.msg);
					window.location.href = url;
				}else{
					alert(res.data.msg);
					window.location.href = '/alipay/pay?WIDout_trade_no='+res.data.order.id+"&WIDtotal_amount="+res.data.order.totalPrice+"&WIDsubject="+res.data.order.productName+"&WIDbody=";
				}
			}
		},
		error: function(res){
			alert("请求失败!");
		}
	});
}